<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>订单融资</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../../../elementUI/index.css">
  <link rel="stylesheet" href="../../../css/index.css">
</head>

<body>
  <div id="app" class="minWidth">
    <el-form :inline="true" :form="form">
      <el-form-item>
        <el-input v-model="form.serachKey" placeholder="请输入内容" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSerach">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" stripe border height="calc(100vh - 140px)" @selection-change="handleSelectionChange"  @expand-change="handleChildren"
      style="width: 100%">
      <el-table-column type="expand" label="明细" width="50">
        <template slot-scope="props">
          <el-table :data="props.row.Children.order_financing_paystages">
            <el-table-column type="index" width="50" label="序号"></el-table-column>
            <el-table-column prop="Quantity" label="本次数量"></el-table-column>
            <el-table-column prop="Amount" label="原金额"></el-table-column>
            <el-table-column prop="Payable_Amount" label="应付金额"></el-table-column>
            <el-table-column prop="Collection_Amount" label="已付金额"></el-table-column>
            <el-table-column prop="Collection_Date" label="付款时间"></el-table-column>
            <el-table-column prop="Row_Status" label="状态">
              <template v-slot="{row}">
                <div style="display: flex; justify-content: center;">
                    <el-tag size="small" v-if="row.Row_Status=='1'">已付款</el-tag>
                </div>
            </template>
            </el-table-column>
            <el-table-column label="操作" width="150">
              <template v-slot="{row}">
                  <el-button v-if="row.Row_Status=='1'" type="primary" size="small" @click="editMember(row)">放货</el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </el-table-column>
      <el-table-column prop="Order_Financing_Name" label="申请人姓名"></el-table-column>
      <el-table-column prop="Order_Financing_Phone" label="联系电话"></el-table-column>
      <el-table-column prop="Enterprise_Name" label="企业名称"></el-table-column>
      <el-table-column prop="Group_Purchasing_SerialNumber" label="寄售交易单号"></el-table-column>
      <el-table-column prop="Group_Purchasing_Name" label="求购商品"></el-table-column>
      <el-table-column prop="Unit_Price" label="单价">
        <template v-slot="{row}">
            {{row.Unit_Price}}/{{row.Article_Unit_SerialNumber}}
        </template>
      </el-table-column>
      <el-table-column prop="Order_Financing_Quantity" label="求购数量">
        <template v-slot="{row}">
            {{row.Order_Financing_Quantity}}{{row.Article_Unit_SerialNumber}}
        </template>
      </el-table-column>
      <el-table-column prop="Quantity_Remain" label="剩余数量">
        <template v-slot="{row}">
            {{row.Quantity_Remain}}{{row.Article_Unit_SerialNumber}}
        </template>
      </el-table-column>
      <el-table-column prop="Interest_Rate" label="利息率">
        <template v-slot="{row}">
            {{toPercent(row.Interest_Rate)}}
        </template>
      </el-table-column>
      <el-table-column prop="Row_Status" width="120" label="状态">
        <template v-slot="{row}">
            <div style="display: flex; justify-content: center;">
                <el-tag type="warning" size="small" v-if="row.Row_Status=='0'">待对方确认</el-tag>
                <el-tag size="small" v-if="row.Row_Status=='1'">待平台买货</el-tag>
                <el-tag type="danger" size="small" v-if="row.Row_Status=='2'">对方未同意</el-tag>
                <el-tag type="success" size="small" v-if="row.Row_Status=='3'">生效中</el-tag>
                <el-tag type="danger" size="small" v-if="row.Row_Status=='3'&&tabDay(new Date(),row.End_Date)">逾期</el-tag>
            </div>
        </template>
      </el-table-column>
      <el-table-column prop="Repayment_Date" label="还款期限">
        <template v-slot="{row}">
          {{row.Repayment_Date}}天
        </template>
      </el-table-column>
      <el-table-column prop="Start_Date" label="生效时间"></el-table-column>
      <el-table-column prop="End_Date" label="结束时间"></el-table-column>
      <el-table-column label="操作" width="150">
        <template v-slot="{row}">
            <el-button v-if="row.Row_Status=='1'" type="primary" size="small" @click="takeEffect(row.Order_Financing_Contract_SerialNumber)">生效</el-button>
            <el-button v-if="row.Row_Status=='3'" type="primary" size="small" @click="editMember(row)">放货</el-button>
            <el-button v-if="row.Row_Status=='3'&&tabDay(new Date(),row.End_Date)" type="danger" size="small" @click="deletMember(row.Order_Financing_SerialNumber)">平仓</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination background v-show="total > 0" @size-change="handleSizeChange" @current-change="handleCurrentChange"
      :current-page="form.page" :page-sizes="[10, 20, 30, 50]" :page-size="form.limit"
      layout="total, sizes, prev, pager, next, jumper" :total="total">
    </el-pagination>
  </div>
  <script type="text/javascript" src="../../../js/jquery-3.6.0.min.js"></script>
  <script type="text/javascript" src="../../../js/jquery.cookie.js"></script>
  <script type="text/javascript" src="../../../js/vue.min.js"></script>
  <script type="text/javascript" src="../../../elementUI/index.js"></script>
  <script type="text/javascript" src="../../../js/utils.js"></script>
  <script type="text/javascript" src="./js/Contract.js"></script>
</body>

</html>